#ifndef Button_First
#define Button_First
#ifdef __GNUG__
#pragma interface
#endif

#include "CompVObject.h"

//---- Button ------------------------------------------------------------------

enum ButtonFlags {
	eButtonIdle     =   BIT(eCompVObjLast+1),
	eButtonLast     =   eCompVObjLast + 1,
	eButtonDefault  =   eCompVObjDefault
};

class Button: public CompositeVObject {
public:
	MetaDef(Button);
	Button(int id= cIdNone, VObject *gop= 0);
	Command *DoLeftButtonDownCommand(Point, Token, int);
	void DoTrackMouse(TrackPhase, Point);
	virtual void Flush(int msec= 200);
	void DrawHighlight(Rectangle);
	void SetOrigin(Point);
	void SetLabel(const char *lb, bool redraw= FALSE);
	Metric GetMinSize();
};

//---- ButtonCommand -----------------------------------------------------------

class ButtonCommand: public Command {
	Button *item;
	bool lastinside, inside;
public:
	ButtonCommand(Button*, bool idle= FALSE);
	void TrackFeedback(Point, Point, bool);
	Command *TrackMouse(TrackPhase, Point, Point, Point);
};

//---- ActionButton ------------------------------------------------------------

enum ActionButtonFlags {
	eActionDefaultButton  = BIT(eButtonLast+1),
	eActionButtonLast     = eButtonLast+1
};

class ActionButton: public Button {
public:
	MetaDef(ActionButton);
	ActionButton(int id= cIdNone, VObject *g= 0, bool dflt= FALSE);
	ActionButton(int id, const char *t, bool dflt= FALSE);

	Metric GetMinSize();
	void DrawInner(Rectangle r, bool highlight);
	void Control(int, int, void*);
};

//---- StateButton -------------------------------------------------------------

class StateButton: public Button {
protected:
	int state;
public:
	MetaDef(StateButton);
	StateButton(int id= cIdNone, int state= 0);
	StateButton(int id, const char *label, int state= 0);
	StateButton(int id, VObject *label, int state= 0);
	virtual void SetValue(int state, bool redraw= TRUE);
	int GetValue();
	void DoTrackMouse(TrackPhase, Point);
	OStream& PrintOn(OStream&);
	IStream& ReadFrom(IStream&);
};

//---- VObjectButton -----------------------------------------------------------

class VObjectButton : public StateButton {
public:
	MetaDef(VObjectButton);
	VObjectButton(int id, VObject *vop, int st= 0);
	Metric GetMinSize();
	void DrawInner(Rectangle r, bool highlight);
};

//---- RadioButton -------------------------------------------------------------

class RadioButton: public StateButton {
public:
	MetaDef(RadioButton);
	RadioButton(int id= cIdNone, bool state= FALSE);
	RadioButton(int id, const char *label, bool state= FALSE);
	RadioButton(int id, VObject *label, bool state= FALSE);
	Metric GetMinSize();
	void SetOrigin(Point);
	void DrawInner(Rectangle r, bool highlight);
};

//---- ToggleButton ------------------------------------------------------------

class ToggleButton: public StateButton {
public:
	MetaDef(ToggleButton);
	ToggleButton(int id= cIdNone, bool state= FALSE);
	ToggleButton(int id, const char *label, bool state= FALSE);
	ToggleButton(int id, VObject *label, bool state= FALSE);
	Metric GetMinSize();
	void SetOrigin(Point);
	void DrawInner(Rectangle r, bool highlight);
};

#endif

